﻿namespace Forms
{
    using Forms.My;
    using Forms.My.Resources;

    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class frmBMWDebKonten : Form
    {
        [AccessedThroughProperty("Abrufen")]
        private DataGridViewCheckBoxColumn _Abrufen;
        [AccessedThroughProperty("BezeichnungDataGridViewTextBoxColumn")]
        private DataGridViewTextBoxColumn _BezeichnungDataGridViewTextBoxColumn;
        [AccessedThroughProperty("btnDeleteRow")]
        private ToolStripButton _btnDeleteRow;
        [AccessedThroughProperty("btnInsertRow")]
        private ToolStripLabel _btnInsertRow;
        [AccessedThroughProperty("btnOK")]
        private Button _btnOK;
        [AccessedThroughProperty("DataGridView1")]
        private DataGridView _DataGridView1;
        [AccessedThroughProperty("DatenschemaBMW")]
        private DatenschemaBMW _DatenschemaBMW;
        [AccessedThroughProperty("DatenschemaBMWBindingSource")]
        private BindingSource _DatenschemaBMWBindingSource;
        [AccessedThroughProperty("DebKtoNrDataGridViewTextBoxColumn")]
        private DataGridViewTextBoxColumn _DebKtoNrDataGridViewTextBoxColumn;
        [AccessedThroughProperty("IDDataGridViewTextBoxColumn")]
        private DataGridViewTextBoxColumn _IDDataGridViewTextBoxColumn;
        [AccessedThroughProperty("ToolStrip1")]
        private ToolStrip _ToolStrip1;
        [AccessedThroughProperty("ToolStripButtonNew")]
        private ToolStripButton _ToolStripButtonNew;
        [AccessedThroughProperty("ToolStripLabel2")]
        private ToolStripLabel _ToolStripLabel2;
        private IContainer components;
        private bool HasShown;

        public frmBMWDebKonten()
        {
            base.FormClosed += new FormClosedEventHandler(this.frmBMWDebKonten_FormClosed);
            base.Shown += new EventHandler(this.frmBMWDebKonten_Shown);
            base.FormClosing += new FormClosingEventHandler(this.frmBMWDebKonten_FormClosing);
            base.Load += new EventHandler(this.frmBMWDebKonten_Load);
            this.HasShown = false;
            this.InitializeComponent();
        }

        private void btnDeleteRow_Click(object sender, EventArgs e)
        {
            this.DataGridView1.CausesValidation = false;
            int index = -1;
            try
            {
                index = this.DataGridView1.CurrentRow.Index;
                this.DataGridView1.CancelEdit();
                // TODO:// Was ist hiermit?
                //this.DataGridView1.CommitEdit(-1);
                // ersetz für die obere Zeile.... keine Ahnung ob das die gleiche Funktionalität besitzt.
                this.DataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
                if (this.DataGridView1.CurrentRow.Index == index)
                {
                    this.DataGridView1.Rows.Remove(this.DataGridView1.CurrentRow);
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
            this.DataGridView1.CausesValidation = true;
        }

        private void btnInsertRow_Click(object sender, EventArgs e)
        {
            try
            {
                this.DataGridView1.Rows[this.DataGridView1.Rows.GetLastRow(0)].Cells[0].Selected = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.DataGridView1.EndEdit();
            MyProject.Forms.Main.cs.Table_BMW_Debitorenkonten.AcceptChanges();
            this.Close();
            this.DialogResult = DialogResult.OK;
        }

        private void DataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            e.Cancel = false;
            if ((this.DataGridView1.IsCurrentCellDirty & this.HasShown) && !this.IsCellValid(this.DataGridView1.CurrentCell))
            {
                e.Cancel = true;
            }
        }

        private void DataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            e.Cancel = true;
        }

        private void DataGridView1_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            e.Cancel = false;
            if ((this.HasShown && (this.DataGridView1.CurrentRow != null)) && !this.DataGridView1.CurrentRow.IsNewRow)
            {
                IEnumerator enumerator = this.DataGridView1.CurrentRow.Cells.GetEnumerator();
                try
                {
                    
                    while (enumerator.MoveNext())
                    {
                        DataGridViewCell current = (DataGridViewCell) enumerator.Current;
                        if (!this.IsCellValid(current))
                        {
                            e.Cancel = true;
                            return;
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
            }
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing && (this.components != null))
                {
                    this.components.Dispose();
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }

        private void frmBMWDebKonten_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.HasShown = false;
        }

        private void frmBMWDebKonten_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.DataGridView1.CancelEdit();
        }

        private void frmBMWDebKonten_Load(object sender, EventArgs e)
        {
            this.DataGridView1.DataSource = MyProject.Forms.Main.cs.Table_BMW_Debitorenkonten;
            this.DataGridView1.Columns["Abrufen"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.DataGridView1.Columns["DebKtoNrDataGridViewTextBoxColumn"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.DataGridView1.Columns["BezeichnungDataGridViewTextBoxColumn"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
        }

        private void frmBMWDebKonten_Shown(object sender, EventArgs e)
        {
            this.HasShown = true;
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            this.components = new Container();
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            this.DataGridView1 = new DataGridView();
            this.Abrufen = new DataGridViewCheckBoxColumn();
            this.btnOK = new Button();
            this.ToolStrip1 = new ToolStrip();
            this.ToolStripButtonNew = new ToolStripButton();
            this.btnInsertRow = new ToolStripLabel();
            this.btnDeleteRow = new ToolStripButton();
            this.ToolStripLabel2 = new ToolStripLabel();
            this.IDDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
            this.DebKtoNrDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
            this.BezeichnungDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
            this.DatenschemaBMWBindingSource = new BindingSource(this.components);
            this.DatenschemaBMW = new DatenschemaBMW();
            ((ISupportInitialize) this.DataGridView1).BeginInit();
            this.ToolStrip1.SuspendLayout();
            ((ISupportInitialize) this.DatenschemaBMWBindingSource).BeginInit();
            this.DatenschemaBMW.BeginInit();
            this.SuspendLayout();
            this.DataGridView1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.DataGridView1.AutoGenerateColumns = false;
            this.DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.DataGridView1.Columns.AddRange(new DataGridViewColumn[] { this.IDDataGridViewTextBoxColumn, this.Abrufen, this.DebKtoNrDataGridViewTextBoxColumn, this.BezeichnungDataGridViewTextBoxColumn });
            this.DataGridView1.DataSource = this.DatenschemaBMWBindingSource;
            Point point = new Point(0, 0x1c);
            this.DataGridView1.Location = point;
            this.DataGridView1.Name = "DataGridView1";
            Size size = new Size(0x20b, 0x19c);
            this.DataGridView1.Size = size;
            this.DataGridView1.TabIndex = 0;
            this.Abrufen.DataPropertyName = "Abrufen";
            this.Abrufen.HeaderText = "\x00dcber Internet abrufen ";
            this.Abrufen.Name = "Abrufen";
            this.btnOK.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            point = new Point(0x1b4, 0x1cd);
            this.btnOK.Location = point;
            this.btnOK.Name = "btnOK";
            size = new Size(0x4b, 0x17);
            this.btnOK.Size = size;
            this.btnOK.TabIndex = 1;
            this.btnOK.Text = "OK";
            this.btnOK.UseVisualStyleBackColor = true;
            this.ToolStrip1.Items.AddRange(new ToolStripItem[] { this.ToolStripButtonNew, this.btnInsertRow, this.btnDeleteRow, this.ToolStripLabel2 });
            point = new Point(0, 0);
            this.ToolStrip1.Location = point;
            this.ToolStrip1.Name = "ToolStrip1";
            size = new Size(0x20b, 0x19);
            this.ToolStrip1.Size = size;
            this.ToolStrip1.TabIndex = 2;
            this.ToolStrip1.Text = "ToolStrip1";
            this.ToolStripButtonNew.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.ToolStripButtonNew.Image = Resources.Symbol_New;
            this.ToolStripButtonNew.ImageTransparentColor = Color.Magenta;
            this.ToolStripButtonNew.Name = "ToolStripButtonNew";
            size = new Size(0x17, 0x16);
            this.ToolStripButtonNew.Size = size;
            this.ToolStripButtonNew.Text = "ToolStripButton1";
            this.btnInsertRow.Name = "btnInsertRow";
            size = new Size(0x45, 0x16);
            this.btnInsertRow.Size = size;
            this.btnInsertRow.Text = "Neues Konto";
            this.btnDeleteRow.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.btnDeleteRow.Image = Resources.Symbol_Delete;
            this.btnDeleteRow.ImageTransparentColor = Color.Magenta;
            this.btnDeleteRow.Name = "btnDeleteRow";
            size = new Size(0x17, 0x16);
            this.btnDeleteRow.Size = size;
            this.btnDeleteRow.Text = "ToolStripButton2";
            this.ToolStripLabel2.Name = "ToolStripLabel2";
            size = new Size(0x4b, 0x16);
            this.ToolStripLabel2.Size = size;
            this.ToolStripLabel2.Text = "Konto löschen";
            this.IDDataGridViewTextBoxColumn.DataPropertyName = "ID";
            style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.IDDataGridViewTextBoxColumn.DefaultCellStyle = style;
            this.IDDataGridViewTextBoxColumn.HeaderText = "ID";
            this.IDDataGridViewTextBoxColumn.Name = "IDDataGridViewTextBoxColumn";
            this.IDDataGridViewTextBoxColumn.Visible = false;
            this.DebKtoNrDataGridViewTextBoxColumn.DataPropertyName = "Deb_Kto_Nr";
            this.DebKtoNrDataGridViewTextBoxColumn.HeaderText = "BMW-Bank Debitoren-Konto-Nr.";
            this.DebKtoNrDataGridViewTextBoxColumn.Name = "DebKtoNrDataGridViewTextBoxColumn";
            this.DebKtoNrDataGridViewTextBoxColumn.Width = 180;
            this.BezeichnungDataGridViewTextBoxColumn.DataPropertyName = "Bezeichnung";
            this.BezeichnungDataGridViewTextBoxColumn.HeaderText = "Bezeichnung";
            this.BezeichnungDataGridViewTextBoxColumn.Name = "BezeichnungDataGridViewTextBoxColumn";
            this.BezeichnungDataGridViewTextBoxColumn.Width = 200;
            this.DatenschemaBMWBindingSource.DataMember = "TAB_BMW_Debitorenkonten";
            this.DatenschemaBMWBindingSource.DataSource = this.DatenschemaBMW;
            this.DatenschemaBMW.DataSetName = "DatenschemaBMW";
            this.DatenschemaBMW.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            size = new Size(0x20b, 0x1f0);
            this.ClientSize = size;
            this.Controls.Add(this.DataGridView1);
            this.Controls.Add(this.ToolStrip1);
            this.Controls.Add(this.btnOK);
            this.Name = "frmBMWDebKonten";
            this.Text = "Internet-Abruf BMW-Debitorenkonten";
            ((ISupportInitialize) this.DataGridView1).EndInit();
            this.ToolStrip1.ResumeLayout(false);
            this.ToolStrip1.PerformLayout();
            ((ISupportInitialize) this.DatenschemaBMWBindingSource).EndInit();
            this.DatenschemaBMW.EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private bool IsCellValid(DataGridViewCell c)
        {
            bool flag2 = true;
            if (this.DataGridView1.Columns[this.DataGridView1.CurrentCell.ColumnIndex].Name.ToUpper() != "DEBKTONRDATAGRIDVIEWTEXTBOXCOLUMN")
            {
                return flag2;
            }
            if (this.DataGridView1.CurrentCell.EditedFormattedValue.ToString().Length == 0)
            {
                Interaction.MsgBox("Sie müssen eine gültige BMW-Debitoren-Konto-Nr. eingeben!", MsgBoxStyle.Exclamation, "Fehler");
                return false;
            }
            long result = -1L;
            if (long.TryParse(Conversions.ToString(this.DataGridView1.CurrentCell.EditedFormattedValue), out result))
            {
                if (result <= 0L)
                {
                    Interaction.MsgBox("Sie müssen eine gültige BMW-Debitoren-Konto-Nr. eingeben!", MsgBoxStyle.Exclamation, "Fehler");
                    flag2 = false;
                }
                return flag2;
            }
            Interaction.MsgBox("Sie müssen eine gültige BMW-Debitoren-Konto-Nr. eingeben!", MsgBoxStyle.Exclamation, "Fehler");
            return false;
        }

        internal virtual DataGridViewCheckBoxColumn Abrufen
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Abrufen;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Abrufen = value;
            }
        }

        internal virtual DataGridViewTextBoxColumn BezeichnungDataGridViewTextBoxColumn
        {
            [DebuggerNonUserCode]
            get
            {
                return this._BezeichnungDataGridViewTextBoxColumn;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._BezeichnungDataGridViewTextBoxColumn = value;
            }
        }

        internal virtual ToolStripButton btnDeleteRow
        {
            [DebuggerNonUserCode]
            get
            {
                return this._btnDeleteRow;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.btnDeleteRow_Click);
                if (this._btnDeleteRow != null)
                {
                    this._btnDeleteRow.Click -= handler;
                }
                this._btnDeleteRow = value;
                if (this._btnDeleteRow != null)
                {
                    this._btnDeleteRow.Click += handler;
                }
            }
        }

        internal virtual ToolStripLabel btnInsertRow
        {
            [DebuggerNonUserCode]
            get
            {
                return this._btnInsertRow;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.btnInsertRow_Click);
                if (this._btnInsertRow != null)
                {
                    this._btnInsertRow.Click -= handler;
                }
                this._btnInsertRow = value;
                if (this._btnInsertRow != null)
                {
                    this._btnInsertRow.Click += handler;
                }
            }
        }

        internal virtual Button btnOK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._btnOK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.btnOK_Click);
                if (this._btnOK != null)
                {
                    this._btnOK.Click -= handler;
                }
                this._btnOK = value;
                if (this._btnOK != null)
                {
                    this._btnOK.Click += handler;
                }
            }
        }

        internal virtual DataGridView DataGridView1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._DataGridView1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                DataGridViewCellValidatingEventHandler handler = new DataGridViewCellValidatingEventHandler(this.DataGridView1_CellValidating);
                DataGridViewDataErrorEventHandler handler2 = new DataGridViewDataErrorEventHandler(this.DataGridView1_DataError);
                DataGridViewCellCancelEventHandler handler3 = new DataGridViewCellCancelEventHandler(this.DataGridView1_RowValidating);
                if (this._DataGridView1 != null)
                {
                    this._DataGridView1.CellValidating -= handler;
                    this._DataGridView1.DataError -= handler2;
                    this._DataGridView1.RowValidating -= handler3;
                }
                this._DataGridView1 = value;
                if (this._DataGridView1 != null)
                {
                    this._DataGridView1.CellValidating += handler;
                    this._DataGridView1.DataError += handler2;
                    this._DataGridView1.RowValidating += handler3;
                }
            }
        }

        internal virtual DatenschemaBMW DatenschemaBMW
        {
            [DebuggerNonUserCode]
            get
            {
                return this._DatenschemaBMW;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._DatenschemaBMW = value;
            }
        }

        internal virtual BindingSource DatenschemaBMWBindingSource
        {
            [DebuggerNonUserCode]
            get
            {
                return this._DatenschemaBMWBindingSource;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._DatenschemaBMWBindingSource = value;
            }
        }

        internal virtual DataGridViewTextBoxColumn DebKtoNrDataGridViewTextBoxColumn
        {
            [DebuggerNonUserCode]
            get
            {
                return this._DebKtoNrDataGridViewTextBoxColumn;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._DebKtoNrDataGridViewTextBoxColumn = value;
            }
        }

        internal virtual DataGridViewTextBoxColumn IDDataGridViewTextBoxColumn
        {
            [DebuggerNonUserCode]
            get
            {
                return this._IDDataGridViewTextBoxColumn;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._IDDataGridViewTextBoxColumn = value;
            }
        }

        internal virtual ToolStrip ToolStrip1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._ToolStrip1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._ToolStrip1 = value;
            }
        }

        internal virtual ToolStripButton ToolStripButtonNew
        {
            [DebuggerNonUserCode]
            get
            {
                return this._ToolStripButtonNew;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._ToolStripButtonNew = value;
            }
        }

        internal virtual ToolStripLabel ToolStripLabel2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._ToolStripLabel2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._ToolStripLabel2 = value;
            }
        }
    }
}

